﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Etapa1.ModelDescription
{
    public class Triangulo
    {
        public Triangulo(Vertice v0, Vertice v1, Vertice v2)
        {
            vertices[0] = v0;
            vertices[1] = v1;
            vertices[2] = v2;          
            
        }

        public void CalculateNormal()
        {
            Vector3 l1 = vertices[0].VertexInfo.Position - vertices[1].VertexInfo.Position;
            Vector3 l2 = vertices[0].VertexInfo.Position - vertices[2].VertexInfo.Position;
            normal  = Vector3.Normalize(Vector3.Cross(l1,l2));
        }

        Vector3 normal;

        public Vector3 Normal
        {
            get { return normal; }
            set { normal = value; }
        }

        Vertice[] vertices = new Vertice[3];

        public Vertice[] Vertices
        {
            get { return vertices; }            
        }
        Edge[] edges = new Edge[3];

        public Edge[] Edges
        {
            get { return edges; }            
        }

        public bool Contains(Vertice ver)
        {
            return vertices.Contains(ver);
        }

    }
}
